﻿<div class="wd-title">
    <img src="@Url.Content("~/Content/logo.png")" class="wd-logo"/>
    <span class="wd-font">水滴实验营</span>
</div>
<div class="weui-cells weui-cells_form">
  
    <div class="weui-cell ">
        <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" id="account" type="tel" placeholder="请填写您的手机号码" />
        </div>
    </div>
    <div class="weui-cell weui-cell_vcode">
        <div class="weui-cell__hd">
            <label class="weui-label">验证码</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="tel" placeholder="请输入短信验证码">
        </div>
        <div class="weui-cell__ft">
            <a href="javascript:;" class="weui-vcode-btn" id="get_code">获取验证码</a>
        </div>
    </div>

</div>

<div class="weui-btn-area">
    <a class="weui-btn weui-btn_primary" href="javascript:" style="width: 90%;" onclick="showCode();" id="showCode">查看邀请码</a>
</div>
<div style="width: 200px; height: 200px; margin: 0 auto; background-color: red;" hidden="hidden" id="div-code"></div>
<script type="text/javascript">
    function showCode() {
        $("#div-code").toggle();
    }
    function senmobile(t) {
        if (issend) {
            //验证电话号码手机号码
            var phoneObj = document.getElementById('account');

            if (phoneObj.value != "") {
                var phoneVal = phoneObj.value;
                var p1 = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
                var me = false;
                if (p1.test(phoneVal)) me = true;
                if (!me) {
                    phoneObj.value = '';
                    weui.toast('请输入正确的手机号码');
                    phoneObj.focus();
                    return false;
                }  else {
                    issend = false;
                    var url = apidomian() + "/Message/Send?tel=" + phoneVal;
                    $.ajax({
                        url: url,
                        type: "GET",
                        success: function (data) {
                            if (data.code == 200) {
                                $("#hidCode").val(data.msg);
                                mui.toast('验证码发送成功！', { verticalAlign: 'center' });
                                for (var i = 1; i <= t; i++) {
                                    window.setTimeout("update_a(" + i + "," + t + ")", i * 1000);
                                }
                            } else {
                                weui.toast('验证码发送失败！');
                                update_a(0, 0);
                            }
                        }
                    });

                }
            } else {
                weui.toast('手机号码不能为空！');
                return false;
            }
        }
    }
    function update_a(num, t) {

        var uCode = document.getElementById('get_code');
        if (num == t) {
            uCode.innerHTML = " 重新发送 ";
        }
        else {
            var printnr = t - num;
            uCode.innerHTML = printnr + " 秒后重发";
        }
    }
</script>
